package com.yanqu.road.logic.activity.foxcard.game.effect;

import com.yanqu.road.entity.activity.foxcard.FoxBaseCard;
import com.yanqu.road.entity.activity.foxcard.FoxHandCard;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;
import com.yanqu.road.utils.string.StringUtils;

import java.util.Collections;
import java.util.List;
import java.util.Set;

/**
 * 打出指定的牌，可以触发加成效果
 * 指定牌|加筹码|乘筹码|加倍率|乘倍率|金币|点数类型集合（1为数字牌，2为人像牌
 */
public class FoxCardEffect6 extends FoxCardEffectBase {
    @Override
    protected void effectHandle(FoxCardGameLogic gameLogic, FoxHandCard handCard) {
        if (triggerType != eFoxCardTriggerType.SCORE) {
            return;
        }

        int pointType = 0;
        if (effectConfig.getParamsList().size() > 6) {
            pointType = Integer.valueOf(effectConfig.getParamsList().get(6));
        }

        boolean isTrigger = false;
        if (pointType == 0) {
            Set<Integer> checkPoints = StringUtils.stringToSet(effectConfig.getParamsList().get(0), ";");
            if (checkPoints.contains(gameLogic.getHandCardNowPoint(handCard))) {
                isTrigger = true;
            }
        } else if (pointType == 2) {
            if (gameLogic.isHeardHandCard(handCard)) {
                isTrigger = true;
            }
        } else if (pointType == 1) {
            if (gameLogic.isNumberHandCard(handCard)) {
                isTrigger = true;
            }
        }


        if (isTrigger) {
            List<FoxBaseCard> foxEffectCards = Collections.singletonList(effectCard);
            gameLogic.addBaseScore(Integer.valueOf(effectConfig.getParamsList().get(1)), foxEffectCards, null); //加基础筹码
            gameLogic.addBaseScoreMulti(Integer.valueOf(effectConfig.getParamsList().get(2)), foxEffectCards, null); //当前基础筹码乘算
            gameLogic.addBaseMulti(Integer.valueOf(effectConfig.getParamsList().get(3)), foxEffectCards, null); //加基础倍率
            gameLogic.addBaseMultiMulti(Integer.valueOf(effectConfig.getParamsList().get(4)), foxEffectCards, null); //当前基础倍率乘算
            gameLogic.goldChange(Integer.valueOf(effectConfig.getParamsList().get(5)), foxEffectCards, null, triggerType); //加金币
        }
    }
}
